package com.globallogic.javatraining.liudmyla_shapoval.uni.people;

import java.util.HashMap;
import com.globallogic.javatraining.liudmyla_shapoval.uni.resources.Course;
import com.globallogic.javatraining.liudmyla_shapoval.uni.resources.Lesson;


public class Student extends Person {

	private int year;
	private String specialty;
	private Course[] coursesTaken;
	
	private HashMap<Lesson, Double> scores = new HashMap<Lesson, Double>();
			
	/**
	 * 
	 * @param year - year of study
	 * @param specialty - student specialization
	 */
	public Student(String firstname, String secondname, int year,
			String specialty) {
		super(firstname, secondname);
		this.year = year;
		this.specialty = specialty;
	}
	
	public Student(String firstname, String secondname) {
		super(firstname, secondname);
	}	
	
	public double getAverageGrade() {
		if (!scores.isEmpty()) {
			double sum = 0.0;
			for (Double g : scores.values()) {
				sum += g;
			}
			return sum / scores.size();
		}
		return 0;
	}
	
	public void rate(Lesson lesson, Double score) {
		if (!scores.containsKey(lesson))	{
			scores.put(lesson, score);
		}
	}
	
	
	
}
